package com.jy.api.signUpReq.stock;

import com.jy.api.domain.ProductMold;
import com.jy.api.domain.StockChangeReason;
import com.jy.api.enums.StockInSourceEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * Created by xiaohua on 2018/7/10.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class InventoryInReq {


    @NotNull(message = "参数错误")
    private String id;

    @NotNull(message = "参数错误")
    private String storeId;

    @NotNull(message = "参数有误")
    private String operatorId;
    @NotNull(message = "参数有误")
    private String operatorName;
    /**
     * 唯一识别码
     */
    private String code;
    /**
     * 入库总金额
     */
    private int totalAmount;

    /**
     * 单据图片地址
     */
    private String receiptFileURL;

    /**
     * 备注
     */
    private String notes;

    private long refId;
    /**
     * 件
     */
    private int quantity;

    /**
     * 出入库原因
     */
    @NotNull(message = "请选择出入库来源")
    private StockChangeReason stockSource;

    /**
     * 出入库地址
     */
    private StockInSourceEnum source;
    /**
     * 是否是原料/商品
     */
    private ProductMold mold;


    @Size(min = 1, message = "请选择入库商品")
    private List<Inventore> inventores;

    private int countNum;

    private int skuCount;



    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Inventore {
        @NotNull(message = "商品Id参数有误")
        private String productId;

        @NotNull(message = "库存Id参数有误")
        private Long invId;

        private String productName;

        @Min(value = 0, message = "入库件数必须大于等于0")
        private int quantity;

        @NotNull(message = "请填写商品规格")
        private int capacity;

        private int amount = 0;

        public int getTotal() {
            return quantity * capacity;
        }


    }


}
